package com.cljh.mapper;

import com.cljh.bean.Product;
import com.cljh.bean.User;
import com.cljh.controller.page.UserPageBean;
import com.cljh.service.UserService;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

//    List<User> selectAllByCondition(@Param("begin")Integer begin, @Param("size") Integer size, @Param("user") User user);


    @Insert("insert into mtmall_test.user (username, pwd, name, gender, vip_number, birthday, money, img,email) values (#{user.username},#{user.pwd},#{user.name},#{user.gender},#{user.vipNumber},#{user.birthday},#{user.money},#{user.img},#{user.email});")
    int save(@Param("user") User user);

    @Delete("delete from mtmall_test.user where id=#{id};")
    int delete(Integer id);

    int update(@Param("user") User user);


    int selectByCount(@Param("user") User user);

    int deleteByIds(@Param("ids") List<Integer> ids);

    User selectById(Integer id);


    @Select("select * from mtmall_test.user;")
    List<User> userList();

    @Select("select id,username from mtmall_test.user;")
    List<User> userList1();


    int saveAll(@Param("users") List<User> users);

    List<User> userConditionList(@Param("begin")Integer begin, @Param("size") Integer size, @Param("user") User user);

    @Select("select count(*) from mtmall_test.user;")
    int countUserNum();

    @Select("select * from mtmall_test.user where username=#{username} ;")
    User selectByUsername(String username);

    @Select("select * from mtmall_test.user where username=#{user.username} and pwd=#{user.pwd};")
    User selectByUsernameAndPwd(@Param("user")User user);


    User selectByEmail(@Param("username")String username,@Param("email") String emailCode);

    User selectByEmailCode(@Param("email") String email);
}
